package main
import (
	"fmt"
	"net"
	"flag"
	)
const(
	_STR_CAP int = 1
)

var TA *net.TCPAddr = &net.TCPAddr{net.IP{127,0,0,1},12345}
var word string

func read(c *net.TCPConn){
	var get []byte = make([]byte,_STR_CAP * 20)
	for{
		_,e := c.Read(get)
		if e != nil {
			c.Close()
			println("Server error!")
			return
		}
		println(string(get))
	}
}

func main(){
	var name *string = flag.String("name","","name")
	flag.Parse()
	println(*name)
	c,_ := net.DialTCP("tcp4",nil,TA)
	var msg []byte = make([]byte,_STR_CAP)
	go read(c)
	for {
		fmt.Scan(&word)
		msg = []byte(word)
		c.Write(msg)
		msg = make([]byte,_STR_CAP)
	}
}
